const https = require("https")
const cors = require("cors")
const express = require("express")
const app = express()
app.use(cors())
const personRouter = require("../router/personRouter")
//路由处理
app.use("/person", personRouter)
app.use(function (req, res, next) {
  var err = new Error("Not Found")
  err.status = 404
  next(err)
})
app.use((err, req, res, next) => {
  res.status(err.status || 500)
  res.json({ status: 500, msg: err.message })
})

const httpServer = app.listen(17777, () => {
  console.log('服务启动 127.0.0.1:17777')
})

httpServer.on("error", (err) => {
  console.log(err)
})

exports.httpServer = httpServer